Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testing: add testing for rewards rate calculation #3336

Closed
wants to merge 3 commits into from
Closed

testing: add testing for rewards rate calculation #3336

wants to merge 3 commits into from

Conversation

AlgoStephenAkiki
Copy link
Contributor

Resolves #3284

Adds additional unit tests for the initial block calculation

Summary

Test Plan

@codecov-commenter
Copy link

codecov-commenter commented Dec 20, 2021

Codecov Report

Merging #3336 (d397af8) into master (850f7c7) will decrease coverage by 0.00%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3336      +/-   ##
==========================================
- Coverage   47.41%   47.40%   -0.01%     
==========================================
  Files         369      369              
  Lines       59667    59667              
==========================================
- Hits        28291    28287       -4     
- Misses      28089    28090       +1     
- Partials     3287     3290       +3     
Impacted Files Coverage Δ
cmd/algoh/blockWatcher.go 77.77% <0.00%> (-3.18%) ⬇️
catchup/service.go 69.07% <0.00%> (-1.50%) ⬇️
catchup/peerSelector.go 98.95% <0.00%> (-1.05%) ⬇️
data/abi/abi_type.go 89.80% <0.00%> (-0.98%) ⬇️
ledger/acctupdates.go 65.39% <0.00%> (-0.39%) ⬇️
network/wsNetwork.go 62.84% <0.00%> (-0.20%) ⬇️
data/transactions/verify/txn.go 44.29% <0.00%> (ø)
data/bookkeeping/block.go 51.30% <0.00%> (+1.11%) ⬆️
network/wsPeer.go 68.33% <0.00%> (+2.50%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 850f7c7...d397af8. Read the comment docs.

@tolikzinovyev
Copy link
Contributor

Looking at it. There is one reviewdog warning if you open the "Files changed" tab.

}{
// Real values gathered from mainnet
{"1", 24000000, 215332, 0, 18500000, config.Consensus[protocol.ConsensusCurrentVersion].MinBalance, 6756334087, 18063999},
{"2", 24000000, 215332, 545321700, 18500000, 10464550021728, 6756334087, 18063999},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that NextRewardsState() logs overflow errors. Did you collect all these parameters atomically?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Under /ledger/internal/eval.go:529 I logged all parameters needed on a node that was sync'd with mainnet.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have ideas why NextRewardsState() logs overflow errors?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't particularly, they showed up after I changed the round count to be multiplied by 3

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there is one issue in the test and one issue in the code.

In the test, the parameters {"2", 24000000, 215332, 545321700, 18500000, 10464550021728, 6756334087, are the ones calculated after round 18063999 is processed. However, the first time NextRewardsState() is called, it is given nextRound = 18063999. It should be one higher.

In the code at https://github.com/AlgoStephenAkiki/go-algorand/blob/feature/3284-test-rewards-rate-calculation/data/bookkeeping/block.go#L321 RewardsRate should be taken from res, not s.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you examine the block headers from mainnet, find the corresponding rounds and verify the above numbers are correct ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wrong about the test code issue, the parameters are for given round - 1. However, the rewards residue for test "4" seems wrong.

@tsachiherman tsachiherman changed the title Added unit tests testing: add testing for rewards rate calculation Jan 10, 2022
tsachiherman pushed a commit that referenced this pull request Jan 19, 2022
## Summary

A modification of #3336. Added a new test where the rewards pool overspends and proposed a fix in `NextRewardsState()` requiring a consensus upgrade.

## Test Plan

This is mostly tests.
@tsachiherman
Copy link
Contributor

These changes were already merged in a separate pr.

jannotti pushed a commit that referenced this pull request Jan 24, 2022
* ledger: fix `NextRewardsState()` (#3403)

## Summary

A modification of #3336. Added a new test where the rewards pool overspends and proposed a fix in `NextRewardsState()` requiring a consensus upgrade.

## Test Plan

This is mostly tests.

* Fix a potential problem of committing non-uniform consensus versions (#3453)

If accountdb accumulates a large backlog, it is possible catchpoint tracker would attempt to commit a wider range than account updates tracker expects.

* avoid generating log error on EnsureValidatedBlock / EnsureBlock (#3424)

In EnsureBlock,, do not log as error message if the error is ledgercore.ErrNonSequentialBlockEval and the block round is in the past (i.e. already in the ledger).

* Fix typo Fulll to Full (#3456)

Fix typo

* Fix worng message on restore crash db. (#3455)

When crash state is found but could not be restored, noCrashState variable is used to report a warning.
However, this variable was set to false in a case where there was no crash state, and the wrong warning was reported.

* Adding new scenario for feature networks (#3451)

Co-authored-by: Tolik Zinovyev <[email protected]>
Co-authored-by: Pavel Zbitskiy <[email protected]>
Co-authored-by: Shant Karakashian <[email protected]>
jannotti pushed a commit that referenced this pull request Jan 25, 2022
* ledger: fix `NextRewardsState()` (#3403)

## Summary

A modification of #3336. Added a new test where the rewards pool overspends and proposed a fix in `NextRewardsState()` requiring a consensus upgrade.

## Test Plan

This is mostly tests.

* Fix a potential problem of committing non-uniform consensus versions (#3453)

If accountdb accumulates a large backlog, it is possible catchpoint tracker would attempt to commit a wider range than account updates tracker expects.

* avoid generating log error on EnsureValidatedBlock / EnsureBlock (#3424)

In EnsureBlock,, do not log as error message if the error is ledgercore.ErrNonSequentialBlockEval and the block round is in the past (i.e. already in the ledger).

* Fix typo Fulll to Full (#3456)

Fix typo

* Fix worng message on restore crash db. (#3455)

When crash state is found but could not be restored, noCrashState variable is used to report a warning.
However, this variable was set to false in a case where there was no crash state, and the wrong warning was reported.

* Adding new scenario for feature networks (#3451)

* Fixing telemetry ports (#3497)

Co-authored-by: Tolik Zinovyev <[email protected]>
Co-authored-by: Pavel Zbitskiy <[email protected]>
Co-authored-by: Shant Karakashian <[email protected]>
Co-authored-by: Jack <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test Rewards Rate Calculation with mainnet values
4 participants